import {listTopicModule, addCompany, listCompany} from '_api/statistic/company'
import {_Promise} from "_libs/util";

export default {
  namespaced: true,
  state: {
    topicModuleList: [],
    companyList: []
  },
  mutations: {
    setTopicModuleList(state, topicModuleList) {
      state.topicModuleList = topicModuleList
    },
    setCompanyList(state, companyList) {
      state.companyList = companyList;
    }
  },
  actions: {
    listTopicModule({commit}, version) {
      return _Promise(listTopicModule(version), res => {
        commit('setTopicModuleList', res.data)
      })
    },

    // 获取所有公司
    listCompany({commit}) {
      return _Promise(listCompany(), res => {
        commit('setCompanyList', res.data)
      })
    },

    // 添加公司
    addCompany(context, company) {
      return _Promise(addCompany(company));
    }
  }
}
